﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using TookKit.Mvvm.Attributes;

namespace TookKit.Mvvm.Extensions
{
    public static class AssemblyExtension
    {
        /// <summary>
        /// 获取程序集中，所有标识为DependencyInjectionAttribute的类型的Type
        /// </summary>
        /// <param name="assembly"></param>
        /// <returns></returns>
        public static List<Type> GetDependencyInjectionTypes(this Assembly assembly)
        {
            var list = assembly.GetTypes();
            var type = typeof(DependencyInjectionAttribute);
            var result = list.Where(t => t.CustomAttributes.Any(p => p.AttributeType == type)).ToList();
            return result;
        }
    }
}
